/*
 *
 * Copyright (c) 2020 The Raptor Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include "src/surface/connector.h"

#include "raptor-lite/impl/config.h"
#include "raptor-lite/impl/property.h"
#ifdef _WIN32
#include "src/windows/tcp_connector.h"
#else
#include "src/linux/tcp_connector.h"
#endif

namespace raptor {

ConnectorAdaptor::ConnectorAdaptor(ConnectorHandler *handler)
    : _impl(new TcpConnector(handler)) {}

ConnectorAdaptor::~ConnectorAdaptor() { delete _impl; }

#ifdef _WIN32
raptor_error ConnectorAdaptor::Init(PollingThread *p, int ms) { return _impl->Init(p, ms); }
#else
raptor_error ConnectorAdaptor::Init(int timeout_ms) { return _impl->Init(1, timeout_ms); }
#endif

raptor_error ConnectorAdaptor::Start() { return _impl->Start(); }

void ConnectorAdaptor::Shutdown() { _impl->Shutdown(); }

raptor_error ConnectorAdaptor::Connect(const std::string &addr, intptr_t user) {
    return _impl->Connect(addr, user);
}

} // namespace raptor
